﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccess.ObjectTwo
{
   public class D_Login
    {
        
        DataTable tb = new DataTable();
        ConnectionToDataBase ex = new ConnectionToDataBase();
        MD5 fx = new MD5();
        public bool checkLogin(String user, String Password)
        {
            String Pass;
            Pass = fx.getMD5(Password);
           
                SqlParameter[] sqlParameters = new SqlParameter[2];
                sqlParameters[0] = new SqlParameter("@User", SqlDbType.VarChar);
                sqlParameters[0].Value = user;
                sqlParameters[1] = new SqlParameter("@Pass", SqlDbType.VarChar);
                sqlParameters[1].Value = Pass;
                try
                {
                tb = ex.executeSelectQuery("CheckLogin", sqlParameters);
                if (tb.Rows.Count > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
              
            }
            catch (Exception ex)
            {
                return false;
            }

        }
        public DataTable Login(String user, String Password)
        {
            String Pass;
            Pass = fx.getMD5(Password);
            SqlParameter[] sqlParameters = new SqlParameter[2];
            sqlParameters[0] = new SqlParameter("@User", SqlDbType.VarChar);
            sqlParameters[0].Value = user;
            sqlParameters[1] = new SqlParameter("@Pass", SqlDbType.VarChar);
            sqlParameters[1].Value = Pass;
            tb = ex.executeSelectQuery("CheckLogin", sqlParameters);
            return tb;
        }
    }
}
